package rootpw;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;

final class AgentBlobFetcher
{
	public String blob;

	AgentBlobFetcher()
	 {
		 URL                       bloburl = null;
		 HttpURLConnection         connection = null;
		 BufferedReader            br = null; 
		 InputStreamReader         ir = null;
		 StringBuilder             response = null;
		 String                    line = null;
		 
		 try {
			bloburl = new URL("http://radar.its.yale.edu/rootpw/password-blob.txt");
	        connection = (HttpURLConnection)bloburl.openConnection();
	        connection.setRequestMethod("GET");
	        connection.connect();
	        	        
	        ir = new InputStreamReader(connection.getInputStream());
	        br = new BufferedReader(ir);
	        response = new StringBuilder();
	       
	        while ((line = br.readLine()) != null)
	        {
	            response.append(line + '\n');
	        }
	        
	        blob = response.toString();
	        
		 } catch (MalformedURLException e) {
			e.printStackTrace();
		 } catch (ProtocolException e) { 
	          e.printStackTrace();
		 } catch (IOException e) {
	          e.printStackTrace();
		 }
		
	     finally {
	          connection.disconnect();
	          ir = null;
	          br = null;
	          connection = null;
	     }
	 }
}
